<style src="./index.scss" lang="scss" scoped rel="stylesheet/scss"></style>
<template src="./index.html"></template>
<script>
    export default {
        mixins: [Vue.prototype.$vFN.Mixins.Base],
        computed: {},
        data() {
            return {
                item: null,
                title: "收银台订单备注",
                form: {
                    storeNote: "",
                },
                // 窗口显示
                boxVisible: false,

            };
        },
        methods: {

            // 验证 
            validate() {
                return new Promise((resolve, reject) => {
                    this.$refs["editForm"].validate((valid) => {
                        valid ? resolve(true) : resolve(false)
                    });
                });
            },
            // 提交
            async submit() {

                if (!await this.validate()) {
                    return
                }
                
                let _data = await this.$vFN.Http.post({
                    url: "plugin/cashier-desk/admin/order/remark",
                    data: {
                        storeNote: this.form.storeNote,
                        orderId: this.item.id
                    },
                },window);
                if (_data._ok) {
                    this.$vFN.Tools.messageSuccess("操作成功");
                    this.editBoxClose();
                    this.onSuccess();
                }
            },
            // 成功回调
            onSuccess() {},
            // 取消回调
            onCancel() {},
            // 失败回调
            onError() {},
            // 关闭窗口
            editBoxClose() {
                this.boxVisible = false;
            },
            // 取消
            editBoxCancel() {
                this.editBoxClose();
            },

            show(e, item) {
                console.log(e, item);
            }
        },
        watch: {},
        async mounted() {
            if (this.item.orderRightsNote) {
                if (this.item.orderRightsNote.note) {
                    this.form.storeNote = this.item.orderRightsNote.note;
                }
            }
            this.boxVisible = true;

        },
        beforeCreate() {},
    };
</script>